package com.bdqn;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;


@MapperScan("com.bdqn.dao")
@EnableEurekaClient   //开启后 自动向注册中心注册服务
@EnableDiscoveryClient //服务发现
@EnableCircuitBreaker    //添加对熔断的支持注解
//@EnableCircuitBreaker //开启断路器功能
//@EnableDiscoveryClient //开启服务发现客户端，
//@SpringBootApplication
//@SpringCloudApplication //可以取代上面三个
@SpringBootApplication
public class Spring_cloud_provider_hystrix_dept_8001_start {

    public static void main(String[] args) {
        SpringApplication.run(Spring_cloud_provider_hystrix_dept_8001_start.class, args);
    }

    //增加一个 Servlet
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        //访问该页面就是监控页面
        registrationBean.addUrlMappings("/actuator/hystrix.stream");

        return registrationBean;
    }
}
